home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # connect-second.cgi
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # $Id: connect-second.cgi,v 1.27 1997/06/19 22:26:46 shotes Exp $
-
- require "/usr/OnRamp/lib/OnRamp.pm";
-
- if (!$ARGV[0]) { printf("Location: %s%c%c","/tasks/Tasks.connect-start.cgi",10,10); }
-
-
- $myname = "connect-second.cgi";
- $temp = "task.tmp";
- $data = "task.dummy";
- $htnet = "/usr/OnRamp/bin/htnetwork";
- $action= "connect-second.cgi?loop";
-
- $it = "<td align=right>";
- $ni = "</td>";
- $bo = "<td><font size=5><i>";
- $nb = "</i></font></td>";
-
- @find_vals = ('hardware','mailserver');
-
- &get_fields;
-
- if ($ARGV[0] eq 'loop') { %vals = %fld; }
- else { &readValues; }
-
- $t1board = &isT1Board;
- $eboard = &isSecondEboard;
-
- if ($ARGV[0] eq loop) {
- &errorCheck;
- &writeFile;
-
- if ($fld{'hardware'} eq 'Modem') { $go = "/tasks/connect-modem.cgi?s"; }
- elsif ($fld{'hardware'} eq 'ISDN') { $go = "/tasks/connect-isdn.cgi?s"; }
- elsif ($fld{'hardware'} eq 'T1') { $go = "/tasks/connect-t1.cgi?s"; }
- elsif ($fld{'hardware'} eq 'Ethernet or FDDI') { $go = "/tasks/connect-ether-fddi.cgi?s"; }
- #printf("Location: %s%c%c",$go,10,10);
- print "Content-type: text/html\n\n";
- print "<HTML><HEAD>";
- print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
- print "</HEAD><BODY></BODY></HTML>";
- exit 0;
- }
-
- &generic;
-
- sub readValues {
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- foreach $arg (@find_vals) {
- if ($arg eq $items[0]) {
- if ($items[1] ne "\n") {
- $vals{$arg} = $items[1];
- chop $vals{$arg};
- }
- }
- }
- }
- close(IN);
- }
-
- sub errorCheck {
- if ($fld{'mailserver'}) {
- &error("Invalid hostname: $fld{'mailserver'}.") if &check_hostname($fld{'mailserver'});
- }
- }
-
- sub isSecondEboard {
- $ret = 0;
- open(IN, "$htnet |");
- while(<IN>) {
- @items = split(/:/);
- if ($items[0] > 0) {
- $ret = 1;
- $last;
- }
- }
- close(IN);
- return $ret;
- }
-
- sub isT1Board {
- $ret = 0;
- open(IN, "$htnet |");
- while(<IN>) {
- @items = split(/\s+/);
- if ($items[0] eq 'GIO') {
- $ret = 1;
- $last;
- }
- }
- close(IN);
- return $ret;
- }
-
- sub error {
- $error = $_[0];
- &generic;
- exit 0;
- }
-
- sub writeFile {
- undef %terms;
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- chop $items[1];
- $terms{$items[0]} = $items[1];
- }
- close(IN);
- foreach $arg (@find_vals) {
- $terms{$arg} = $fld{$arg};
- }
- open(OUT,"> $temp");
- foreach $arg (keys(%terms)) {
- print OUT "$arg=$terms{$arg}\n";
- }
- close(OUT);
- }
-
- sub generic {
- print "Content-type: text/html\n\n";
- print "<html><head><title>Connect to the Internet (continued)</title>\n";
- print "<script language=\"JavaScript\">\n<!--\n";
-
- # JavaScript
- print "function Next() {
- form = document.page2;
- if (!testMailserver(form)) return;
- setTimeout('form.submit()',0);
- return;
- }\n";
- print "function Previous() {
- setTimeout('window.location=\"Tasks.connect-start.cgi?s\"',0);
- return;
- }\n";
- print "function testMailserver(form) {
- Ctrl = form.mailserver;
- if (Ctrl.value == \"\") return (true);
- error = testHost(Ctrl.value);
- if (error == 1) { errorBox (Ctrl, \"The forwarder hostname cannot contain \\npunctuation except . or - or _\"); return (false); }
- if (error == 2) { errorBox (Ctrl, \"The forwarder hostname cannot begin or \\n end with a . or - or _ character.\"); return (false); }
- if (error == 3) { errorBox (Ctrl, \"The forwarder hostname cannot contain \\nconsecutive . or - or _ characters.\"); return (false); }
- if (error == 4) { errorBox (Ctrl, \"The forwarder hostname cannot contain spaces.\"); return (false); }
- if (error == 5) { errorBox (Ctrl, \"The forwarder hostname cannot begin \\nwith a number.\"); return (false); }
- return (true);
- }\n";
- print "function testHost(word) {
- metaChars = \"{}()*!~<>?|[]'&^\$\@\#`\\\";:\\\\/+=,%\";
- start = 0; while (word.charAt(start) == ' ') { start++; }
- end = word.length-1; while (word.charAt(end) == ' ') { end--; }
- for(j = 0; j < metaChars.length; j++) {
- c = metaChars.charAt(j); i = word.indexOf(c, 0); if (i != -1) return 1;
- }
- sch = word.charAt(start); ech = word.charAt(end);
- if(sch == '.' || sch == '-' || sch == '_') return 2;
- if(ech == '.' || ech == '-' || ech == '_') return 2;
- for(j = start; j <= end; j++) { ch = word.charAt(j); if (ch == '.' || ch ==
- '-' || ch == '_') { if (word.charAt(j+1) == ch) return 3; } if (ch == ' ') { return 4; } }
- if(!isNaN(parseInt(sch))) return 5;
- return 0;
- }\n";
- print "function errorBox (Ctrl, ErrorMessage) {
- alert (ErrorMessage); Ctrl.focus(); return;
- }\n";
-
- print "//-->\n";
- print "</script></head>\n\n";
-
- print "<body bgcolor=\'c7ded4\' background=/tasks/connect-task.bg.gif>\n";
-
- if ($error) {
- print "<font size=4 color=ff0000><b>Error: </b>$error<br></font>";
- }
- print "<i>$message</i>";
-
- print "<table width=100%>",
- "<tr><th align=left><h1>Connect to the Internet (continued)</h1></th>\n",
- "<th align=right><a href=\"/newsplash.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/home.gif></a>\n",
- " <a href=\"Tasks.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
- "</tr></table>\n";
-
- printf("\n<form name=\"page2\" action=\"%s\" method=post>\n", $action);
-
- print "<center><table width=620>";
-
- @list = ('Modem','ISDN');
- if ($t1board) { push(@list,"T1"); }
- if ($eboard) { push(@list,"Ethernet or FDDI"); }
-
- print "<tr>$bo Hostname of the mail forwarder: $nb $it\n",
- &text("mailserver",$vals{'mailserver'},15),
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- To send mail outside your local network, your ISP might have
- supplied the name of a mail forwarder host. If your ISP supplied
- the hostname of a mail forwarder, enter it in this field (not
- required unless supplied by your ISP). Your entry must be a fully
- qualified hostname, such as <I>juggler.abc.com</I>.";
-
- print "<tr><td> </td></tr>\n";
-
- print "<tr>$bo Type of hardware connection to your
- ISP: $nb $it <font size=4>\n",
- &select_list("hardware",$vals{'hardware'},*list),
- "</font>$ni </tr>\n";
- print " <tr><td colspan=2>
- The communications hardware that links the Internet Gateway and
- an ISP is either a modem and serial line, ISDN service, a T1 line,
- or Ethernet hardware. Use the options menu above to select the type
- of hardware that connects the Internet Gateway to your ISP.
- </td></tr><tr><td> </td></tr></table>\n\n";
-
- print '<MAP NAME="js_map1">',
- ' <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Previous()"
- onMouseOver="window.status=\'\';return true">',
- '</MAP>';
- print "\n";
- print '<MAP NAME="js_map2">',
- ' <AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Next()"
- onMouseOver="window.status=\'\';return true">',
- '</MAP>';
- print "\n";
- print '<IMG SRC="/tasks/rightarrow.gif" BORDER=0 USEMAP="#js_map2" align="right">';
- print "\n";
- print '<IMG SRC="/tasks/leftarrow.gif" BORDER=0 USEMAP="#js_map1" align="right">';
-
- print "\n</form></body></html>";
- }
-
-